home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libimgfile.tex < prev    next >
LaTeX Document  |  1994-08-08  |  2.7 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: libimgfile.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 6d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n module| \sectco|
|00000020| 64 65 7b 69 6d 67 66 69 | 6c 65 7d 7d 0d 5c 62 69 |de{imgfi|le}}.\bi|
|00000030| 6d 6f 64 69 6e 64 65 78 | 7b 69 6d 67 66 69 6c 65 |modindex|{imgfile|
|00000040| 7d 0d 0d 54 68 65 20 69 | 6d 67 66 69 6c 65 20 6d |}..The i|mgfile m|
|00000050| 6f 64 75 6c 65 20 61 6c | 6c 6f 77 73 20 70 79 74 |odule al|lows pyt|
|00000060| 68 6f 6e 20 70 72 6f 67 | 72 61 6d 73 20 74 6f 20 |hon prog|rams to |
|00000070| 61 63 63 65 73 73 20 53 | 47 49 20 69 6d 67 6c 69 |access S|GI imgli|
|00000080| 62 20 69 6d 61 67 65 0d | 66 69 6c 65 73 20 28 61 |b image.|files (a|
|00000090| 6c 73 6f 20 6b 6e 6f 77 | 6e 20 61 73 20 5c 66 69 |lso know|n as \fi|
|000000a0| 6c 65 7b 2e 72 67 62 7d | 20 66 69 6c 65 73 29 2e |le{.rgb}| files).|
|000000b0| 20 20 54 68 65 20 6d 6f | 64 75 6c 65 20 69 73 20 | The mo|dule is |
|000000c0| 66 61 72 20 66 72 6f 6d | 0d 63 6f 6d 70 6c 65 74 |far from|.complet|
|000000d0| 65 2c 20 62 75 74 20 69 | 73 20 70 72 6f 76 69 64 |e, but i|s provid|
|000000e0| 65 64 20 61 6e 79 77 61 | 79 20 73 69 6e 63 65 20 |ed anywa|y since |
|000000f0| 74 68 65 20 66 75 6e 63 | 74 69 6f 6e 61 6c 69 74 |the func|tionalit|
|00000100| 79 20 74 68 61 74 20 74 | 68 65 72 65 20 69 73 0d |y that t|here is.|
|00000110| 69 73 20 65 6e 6f 75 67 | 68 20 69 6e 20 73 6f 6d |is enoug|h in som|
|00000120| 65 20 63 61 73 65 73 2e | 20 20 43 75 72 72 65 6e |e cases.| Curren|
|00000130| 74 6c 79 2c 20 63 6f 6c | 6f 72 6d 61 70 20 66 69 |tly, col|ormap fi|
|00000140| 6c 65 73 20 61 72 65 20 | 6e 6f 74 20 73 75 70 70 |les are |not supp|
|00000150| 6f 72 74 65 64 2e 0d 0d | 54 68 65 20 6d 6f 64 75 |orted...|The modu|
|00000160| 6c 65 20 64 65 66 69 6e | 65 73 20 74 68 65 20 66 |le defin|es the f|
|00000170| 6f 6c 6c 6f 77 69 6e 67 | 20 76 61 72 69 61 62 6c |ollowing| variabl|
|00000180| 65 73 20 61 6e 64 20 66 | 75 6e 63 74 69 6f 6e 73 |es and f|unctions|
|00000190| 3a 0d 0d 5c 72 65 6e 65 | 77 63 6f 6d 6d 61 6e 64 |:..\rene|wcommand|
|000001a0| 7b 5c 69 6e 64 65 78 73 | 75 62 69 74 65 6d 7d 7b |{\indexs|ubitem}{|
|000001b0| 28 69 6e 20 6d 6f 64 75 | 6c 65 20 69 6d 67 66 69 |(in modu|le imgfi|
|000001c0| 6c 65 29 7d 0d 5c 62 65 | 67 69 6e 7b 65 78 63 64 |le)}.\be|gin{excd|
|000001d0| 65 73 63 7d 7b 65 72 72 | 6f 72 7d 0d 54 68 69 73 |esc}{err|or}.This|
|000001e0| 20 65 78 63 65 70 74 69 | 6f 6e 20 69 73 20 72 61 | excepti|on is ra|
|000001f0| 69 73 65 64 20 6f 6e 20 | 61 6c 6c 20 65 72 72 6f |ised on |all erro|
|00000200| 72 73 2c 20 73 75 63 68 | 20 61 73 20 75 6e 73 75 |rs, such| as unsu|
|00000210| 70 70 6f 72 74 65 64 20 | 66 69 6c 65 20 74 79 70 |pported |file typ|
|00000220| 65 2c 20 65 74 63 2e 0d | 5c 65 6e 64 7b 65 78 63 |e, etc..|\end{exc|
|00000230| 64 65 73 63 7d 0d 0d 5c | 62 65 67 69 6e 7b 66 75 |desc}..\|begin{fu|
|00000240| 6e 63 64 65 73 63 7d 7b | 67 65 74 73 69 7a 65 73 |ncdesc}{|getsizes|
|00000250| 7d 7b 66 69 6c 65 7d 0d | 54 68 69 73 20 66 75 6e |}{file}.|This fun|
|00000260| 63 74 69 6f 6e 20 72 65 | 74 75 72 6e 73 20 61 20 |ction re|turns a |
|00000270| 74 75 70 6c 65 20 5c 63 | 6f 64 65 7b 28 5c 76 61 |tuple \c|ode{(\va|
|00000280| 72 7b 78 7d 2c 20 5c 76 | 61 72 7b 79 7d 2c 20 5c |r{x}, \v|ar{y}, \|
|00000290| 76 61 72 7b 7a 7d 29 7d | 20 77 68 65 72 65 0d 5c |var{z})}| where.\|
|000002a0| 76 61 72 7b 78 7d 20 61 | 6e 64 20 5c 76 61 72 7b |var{x} a|nd \var{|
|000002b0| 79 7d 20 61 72 65 20 74 | 68 65 20 73 69 7a 65 20 |y} are t|he size |
|000002c0| 6f 66 20 74 68 65 20 69 | 6d 61 67 65 20 69 6e 20 |of the i|mage in |
|000002d0| 70 69 78 65 6c 73 20 61 | 6e 64 0d 5c 76 61 72 7b |pixels a|nd.\var{|
|000002e0| 7a 7d 20 69 73 20 74 68 | 65 20 6e 75 6d 62 65 72 |z} is th|e number|
|000002f0| 20 6f 66 0d 62 79 74 65 | 73 20 70 65 72 20 70 69 | of.byte|s per pi|
|00000300| 78 65 6c 2e 20 4f 6e 6c | 79 20 33 20 62 79 74 65 |xel. Onl|y 3 byte|
|00000310| 20 52 47 42 20 70 69 78 | 65 6c 73 20 61 6e 64 20 | RGB pix|els and |
|00000320| 31 20 62 79 74 65 20 67 | 72 65 79 73 63 61 6c 65 |1 byte g|reyscale|
|00000330| 20 70 69 78 65 6c 73 0d | 61 72 65 20 63 75 72 72 | pixels.|are curr|
|00000340| 65 6e 74 6c 79 20 73 75 | 70 70 6f 72 74 65 64 2e |ently su|pported.|
|00000350| 0d 5c 65 6e 64 7b 66 75 | 6e 63 64 65 73 63 7d 0d |.\end{fu|ncdesc}.|
|00000360| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00000370| 7d 7b 72 65 61 64 7d 7b | 66 69 6c 65 7d 0d 54 68 |}{read}{|file}.Th|
|00000380| 69 73 20 66 75 6e 63 74 | 69 6f 6e 20 72 65 61 64 |is funct|ion read|
|00000390| 73 20 61 6e 64 20 64 65 | 63 6f 64 65 73 20 74 68 |s and de|codes th|
|000003a0| 65 20 69 6d 61 67 65 20 | 6f 6e 20 74 68 65 20 73 |e image |on the s|
|000003b0| 70 65 63 69 66 69 65 64 | 20 66 69 6c 65 2c 20 61 |pecified| file, a|
|000003c0| 6e 64 0d 72 65 74 75 72 | 6e 73 20 69 74 20 61 73 |nd.retur|ns it as|
|000003d0| 20 61 20 70 79 74 68 6f | 6e 20 73 74 72 69 6e 67 | a pytho|n string|
|000003e0| 2e 20 54 68 65 20 73 74 | 72 69 6e 67 20 68 61 73 |. The st|ring has|
|000003f0| 20 65 69 74 68 65 72 20 | 31 20 62 79 74 65 20 67 | either |1 byte g|
|00000400| 72 65 79 73 63 61 6c 65 | 0d 70 69 78 65 6c 73 20 |reyscale|.pixels |
|00000410| 6f 72 20 34 20 62 79 74 | 65 20 52 47 42 41 20 70 |or 4 byt|e RGBA p|
|00000420| 69 78 65 6c 73 2e 20 54 | 68 65 20 62 6f 74 74 6f |ixels. T|he botto|
|00000430| 6d 20 6c 65 66 74 20 70 | 69 78 65 6c 20 69 73 20 |m left p|ixel is |
|00000440| 74 68 65 20 66 69 72 73 | 74 20 69 6e 0d 74 68 65 |the firs|t in.the|
|00000450| 20 73 74 72 69 6e 67 2e | 20 54 68 69 73 20 66 6f | string.| This fo|
|00000460| 72 6d 61 74 20 69 73 20 | 73 75 69 74 61 62 6c 65 |rmat is |suitable|
|00000470| 20 74 6f 20 70 61 73 73 | 20 74 6f 20 5c 63 6f 64 | to pass| to \cod|
|00000480| 65 7b 67 6c 2e 6c 72 65 | 63 74 77 72 69 74 65 7d |e{gl.lre|ctwrite}|
|00000490| 2c 0d 66 6f 72 20 69 6e | 73 74 61 6e 63 65 2e 0d |,.for in|stance..|
|000004a0| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0d 0d |\end{fun|cdesc}..|
|000004b0| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|000004c0| 7b 72 65 61 64 73 63 61 | 6c 65 64 7d 7b 66 69 6c |{readsca|led}{fil|
|000004d0| 65 5c 2c 20 78 5c 2c 20 | 79 5c 2c 20 66 69 6c 74 |e\, x\, |y\, filt|
|000004e0| 65 72 5c 6f 70 74 69 6f | 6e 61 6c 7b 5c 2c 20 62 |er\optio|nal{\, b|
|000004f0| 6c 75 72 7d 7d 0d 54 68 | 69 73 20 66 75 6e 63 74 |lur}}.Th|is funct|
|00000500| 69 6f 6e 20 69 73 20 69 | 64 65 6e 74 69 63 61 6c |ion is i|dentical|
|00000510| 20 74 6f 20 72 65 61 64 | 20 62 75 74 20 69 74 20 | to read| but it |
|00000520| 72 65 74 75 72 6e 73 20 | 61 6e 20 69 6d 61 67 65 |returns |an image|
|00000530| 20 74 68 61 74 20 69 73 | 0d 73 63 61 6c 65 64 20 | that is|.scaled |
|00000540| 74 6f 20 74 68 65 20 67 | 69 76 65 6e 20 5c 76 61 |to the g|iven \va|
|00000550| 72 7b 78 7d 20 61 6e 64 | 20 5c 76 61 72 7b 79 7d |r{x} and| \var{y}|
|00000560| 20 73 69 7a 65 73 2e 20 | 49 66 20 74 68 65 20 5c | sizes. |If the \|
|00000570| 76 61 72 7b 66 69 6c 74 | 65 72 7d 20 61 6e 64 0d |var{filt|er} and.|
|00000580| 5c 76 61 72 7b 62 6c 75 | 72 7d 20 70 61 72 61 6d |\var{blu|r} param|
|00000590| 65 74 65 72 73 20 61 72 | 65 20 6f 6d 69 74 74 65 |eters ar|e omitte|
|000005a0| 64 20 73 63 61 6c 69 6e | 67 20 69 73 20 64 6f 6e |d scalin|g is don|
|000005b0| 65 20 62 79 0d 73 69 6d | 70 6c 79 20 64 72 6f 70 |e by.sim|ply drop|
|000005c0| 70 69 6e 67 20 6f 72 20 | 64 75 70 6c 69 63 61 74 |ping or |duplicat|
|000005d0| 69 6e 67 20 70 69 78 65 | 6c 73 2c 20 73 6f 20 74 |ing pixe|ls, so t|
|000005e0| 68 65 20 72 65 73 75 6c | 74 20 77 69 6c 6c 20 62 |he resul|t will b|
|000005f0| 65 20 6c 65 73 73 20 74 | 68 61 6e 0d 70 65 72 66 |e less t|han.perf|
|00000600| 65 63 74 2c 20 65 73 70 | 65 63 69 61 6c 6c 79 20 |ect, esp|ecially |
|00000610| 66 6f 72 20 63 6f 6d 70 | 75 74 65 72 2d 67 65 6e |for comp|uter-gen|
|00000620| 65 72 61 74 65 64 20 69 | 6d 61 67 65 73 2e 0d 0d |erated i|mages...|
|00000630| 41 6c 74 65 72 6e 61 74 | 69 76 65 6c 79 2c 20 79 |Alternat|ively, y|
|00000640| 6f 75 20 63 61 6e 20 73 | 70 65 63 69 66 79 20 61 |ou can s|pecify a|
|00000650| 20 66 69 6c 74 65 72 20 | 74 6f 20 75 73 65 20 74 | filter |to use t|
|00000660| 6f 20 73 6d 6f 6f 74 68 | 65 6e 20 74 68 65 20 69 |o smooth|en the i|
|00000670| 6d 61 67 65 0d 61 66 74 | 65 72 20 73 63 61 6c 69 |mage.aft|er scali|
|00000680| 6e 67 2e 20 54 68 65 20 | 66 69 6c 74 65 72 20 66 |ng. The |filter f|
|00000690| 6f 72 6d 73 20 73 75 70 | 70 6f 72 74 65 64 20 61 |orms sup|ported a|
|000006a0| 72 65 20 5c 63 6f 64 65 | 7b 27 69 6d 70 75 6c 73 |re \code|{'impuls|
|000006b0| 65 27 7d 2c 0d 5c 63 6f | 64 65 7b 27 62 6f 78 27 |e'},.\co|de{'box'|
|000006c0| 7d 2c 20 5c 63 6f 64 65 | 7b 27 74 72 69 61 6e 67 |}, \code|{'triang|
|000006d0| 6c 65 27 7d 2c 20 5c 63 | 6f 64 65 7b 27 71 75 61 |le'}, \c|ode{'qua|
|000006e0| 64 72 61 74 69 63 27 7d | 20 61 6e 64 0d 5c 63 6f |dratic'}| and.\co|
|000006f0| 64 65 7b 27 67 61 75 73 | 73 69 61 6e 27 7d 2e 20 |de{'gaus|sian'}. |
|00000700| 49 66 20 61 20 66 69 6c | 74 65 72 20 69 73 20 73 |If a fil|ter is s|
|00000710| 70 65 63 69 66 69 65 64 | 20 5c 76 61 72 7b 62 6c |pecified| \var{bl|
|00000720| 75 72 7d 20 69 73 20 61 | 6e 20 6f 70 74 69 6f 6e |ur} is a|n option|
|00000730| 61 6c 0d 70 61 72 61 6d | 65 74 65 72 20 73 70 65 |al.param|eter spe|
|00000740| 63 69 66 79 69 6e 67 20 | 74 68 65 20 62 6c 75 72 |cifying |the blur|
|00000750| 72 69 6e 65 73 73 20 6f | 66 20 74 68 65 20 66 69 |riness o|f the fi|
|00000760| 6c 74 65 72 2e 20 49 74 | 20 64 65 66 61 75 6c 74 |lter. It| default|
|00000770| 73 20 74 6f 20 5c 63 6f | 64 65 7b 31 2e 30 7d 2e |s to \co|de{1.0}.|
|00000780| 0d 0d 5c 63 6f 64 65 7b | 72 65 61 64 73 63 61 6c |..\code{|readscal|
|00000790| 65 64 7d 20 6d 61 6b 65 | 73 20 6e 6f 0d 61 74 74 |ed} make|s no.att|
|000007a0| 65 6d 70 74 20 74 6f 20 | 6b 65 65 70 20 74 68 65 |empt to |keep the|
|000007b0| 20 61 73 70 65 63 74 20 | 72 61 74 69 6f 20 63 6f | aspect |ratio co|
|000007c0| 72 72 65 63 74 2c 20 73 | 6f 20 74 68 61 74 20 69 |rrect, s|o that i|
|000007d0| 73 20 74 68 65 20 75 73 | 65 72 73 27 0d 72 65 73 |s the us|ers'.res|
|000007e0| 70 6f 6e 73 69 62 69 6c | 69 74 79 2e 0d 5c 65 6e |ponsibil|ity..\en|
|000007f0| 64 7b 66 75 6e 63 64 65 | 73 63 7d 0d 0d 5c 62 65 |d{funcde|sc}..\be|
|00000800| 67 69 6e 7b 66 75 6e 63 | 64 65 73 63 7d 7b 74 74 |gin{func|desc}{tt|
|00000810| 6f 62 7d 7b 66 6c 61 67 | 7d 0d 54 68 69 73 20 66 |ob}{flag|}.This f|
|00000820| 75 6e 63 74 69 6f 6e 20 | 73 65 74 73 20 61 20 67 |unction |sets a g|
|00000830| 6c 6f 62 61 6c 20 66 6c | 61 67 20 77 68 69 63 68 |lobal fl|ag which|
|00000840| 20 64 65 66 69 6e 65 73 | 20 77 68 65 74 68 65 72 | defines| whether|
|00000850| 20 74 68 65 20 73 63 61 | 6e 20 6c 69 6e 65 73 0d | the sca|n lines.|
|00000860| 6f 66 20 74 68 65 20 69 | 6d 61 67 65 20 61 72 65 |of the i|mage are|
|00000870| 20 72 65 61 64 20 6f 72 | 20 77 72 69 74 74 65 6e | read or| written|
|00000880| 20 66 72 6f 6d 20 62 6f | 74 74 6f 6d 20 74 6f 20 | from bo|ttom to |
|00000890| 74 6f 70 20 28 66 6c 61 | 67 20 69 73 20 7a 65 72 |top (fla|g is zer|
|000008a0| 6f 2c 0d 63 6f 6d 70 61 | 74 69 62 6c 65 20 77 69 |o,.compa|tible wi|
|000008b0| 74 68 20 53 47 49 20 47 | 4c 29 20 6f 72 20 66 72 |th SGI G|L) or fr|
|000008c0| 6f 6d 20 74 6f 70 20 74 | 6f 20 62 6f 74 74 6f 6d |om top t|o bottom|
|000008d0| 28 66 6c 61 67 20 69 73 | 20 6f 6e 65 2c 0d 63 6f |(flag is| one,.co|
|000008e0| 6d 70 61 74 69 62 6c 65 | 20 77 69 74 68 20 58 29 |mpatible| with X)|
|000008f0| 2e 20 20 54 68 65 20 64 | 65 66 61 75 6c 74 20 69 |. The d|efault i|
|00000900| 73 20 7a 65 72 6f 2e 0d | 5c 65 6e 64 7b 66 75 6e |s zero..|\end{fun|
|00000910| 63 64 65 73 63 7d 0d 0d | 5c 62 65 67 69 6e 7b 66 |cdesc}..|\begin{f|
|00000920| 75 6e 63 64 65 73 63 7d | 7b 77 72 69 74 65 7d 7b |uncdesc}|{write}{|
|00000930| 66 69 6c 65 5c 2c 20 64 | 61 74 61 5c 2c 20 78 5c |file\, d|ata\, x\|
|00000940| 2c 20 79 5c 2c 20 7a 7d | 0d 54 68 69 73 20 66 75 |, y\, z}|.This fu|
|00000950| 6e 63 74 69 6f 6e 20 77 | 72 69 74 65 73 20 74 68 |nction w|rites th|
|00000960| 65 20 52 47 42 20 6f 72 | 20 67 72 65 79 73 63 61 |e RGB or| greysca|
|00000970| 6c 65 20 64 61 74 61 20 | 69 6e 20 5c 76 61 72 7b |le data |in \var{|
|00000980| 64 61 74 61 7d 20 74 6f | 20 69 6d 61 67 65 0d 66 |data} to| image.f|
|00000990| 69 6c 65 20 5c 76 61 72 | 7b 66 69 6c 65 7d 2e 20 |ile \var|{file}. |
|000009a0| 5c 76 61 72 7b 78 7d 20 | 61 6e 64 20 5c 76 61 72 |\var{x} |and \var|
|000009b0| 7b 79 7d 20 67 69 76 65 | 20 74 68 65 20 73 69 7a |{y} give| the siz|
|000009c0| 65 20 6f 66 20 74 68 65 | 20 69 6d 61 67 65 2c 0d |e of the| image,.|
|000009d0| 5c 76 61 72 7b 7a 7d 20 | 69 73 20 31 20 66 6f 72 |\var{z} |is 1 for|
|000009e0| 20 31 20 62 79 74 65 20 | 67 72 65 79 73 63 61 6c | 1 byte |greyscal|
|000009f0| 65 20 69 6d 61 67 65 73 | 20 6f 72 20 33 20 66 6f |e images| or 3 fo|
|00000a00| 72 20 52 47 42 20 69 6d | 61 67 65 73 20 28 77 68 |r RGB im|ages (wh|
|00000a10| 69 63 68 20 61 72 65 0d | 73 74 6f 72 65 64 20 61 |ich are.|stored a|
|00000a20| 73 20 34 20 62 79 74 65 | 20 76 61 6c 75 65 73 20 |s 4 byte| values |
|00000a30| 6f 66 20 77 68 69 63 68 | 20 6f 6e 6c 79 20 74 68 |of which| only th|
|00000a40| 65 20 6c 6f 77 65 72 20 | 74 68 72 65 65 20 62 79 |e lower |three by|
|00000a50| 74 65 73 20 61 72 65 20 | 75 73 65 64 29 2e 0d 54 |tes are |used)..T|
|00000a60| 68 65 73 65 20 61 72 65 | 20 74 68 65 20 66 6f 72 |hese are| the for|
|00000a70| 6d 61 74 73 20 72 65 74 | 75 72 6e 65 64 20 62 79 |mats ret|urned by|
|00000a80| 20 5c 63 6f 64 65 7b 67 | 6c 2e 6c 72 65 63 74 72 | \code{g|l.lrectr|
|00000a90| 65 61 64 7d 2e 0d 5c 65 | 6e 64 7b 66 75 6e 63 64 |ead}..\e|nd{funcd|
|00000aa0| 65 73 63 7d 0d | |esc}. | |
+--------+-------------------------+-------------------------+--------+--------+